package crudfx.control;
import javax.swing.table.*;
import javax.swing.event.*;
import java.awt.event.*;
import java.awt.*;
import javax.swing.*;
import javax.swing.border.*;
import javafx.scene.paint.*;
import crudfx.interop.*;
import crudfx.field.*;
/**
 * @profile desktop
 * @author Sergey Surikov
 */
public class ArtGrid  extends StandardGrid{
    public var cell:ArtGridCell;
    //public var selectedCell:ArtGridCell;
    public var header:ArtGridCell;
    public var upOn:ImageIcon;
    public var upOff:ImageIcon;
    public var downOn:ImageIcon;
    public var downOff:ImageIcon;
    public var leftOn:ImageIcon;
    public var leftOff:ImageIcon;
    public var rightOn:ImageIcon;
    public var rightOff:ImageIcon;
    public var verticalTrack:UIComponent;
    public var verticalThumb:UIComponent;
    public var horizontalTrack:UIComponent;
    public var horizontalThumb:UIComponent;
    override protected function recreateColumns():Void{
        super.recreateColumns();
        GridTools.setupArtGrid(table
            ,cell.getJComponent() as JLabel
            //,selectedCell.getJComponent() as JLabel
            ,header.getJComponent() as JLabel
            );
        }
    override public function getJComponent(): JComponent{
        table.setShowGrid(false);
        scrollPane.getViewport().setOpaque(false);
        scrollPane.setBorder(new javax.swing.border.EmptyBorder(0,0,0,0));
        scrollPane.setViewportBorder(new javax.swing.border.EmptyBorder(0,0,0,0));
        table.setOpaque(false);
        scrollPane.setOpaque(false);
        if(cell==null)cell=ArtGridCell{};
        //if(selectedCell==null)selectedCell=ArtGridCell{};
        if(header==null)header=ArtGridCell{};
        GridTools.setupArtGrid(table
            ,cell.getJComponent() as JLabel
            //,selectedCell.getJComponent() as JLabel
            ,header.getJComponent() as JLabel
            );
        var verticalThumbPanel:JPanel=new JPanel(false);
        var verticalTrackPanel:JPanel=new JPanel(false);
        var horizontalThumbPanel:JPanel=new JPanel(false);
        var horizontalTrackPanel:JPanel=new JPanel(false);
        verticalThumbPanel.setOpaque(false);
        verticalThumbPanel.setLayout(new BorderLayout());
        if(verticalThumb==null)verticalThumb=StandardLabel{};
        verticalThumbPanel.add(verticalThumb.getJComponent(),java.awt.BorderLayout.CENTER);
        verticalTrackPanel.setOpaque(false);
        verticalTrackPanel.setLayout(new BorderLayout());
        if(verticalTrack==null)verticalTrack=StandardLabel{};
        verticalTrackPanel.add(verticalTrack.getJComponent(),java.awt.BorderLayout.CENTER);
        horizontalThumbPanel.setOpaque(false);
        horizontalThumbPanel.setLayout(new BorderLayout());
        if(horizontalThumb==null)horizontalThumb=StandardLabel{};
        horizontalThumbPanel.add(horizontalThumb.getJComponent(),java.awt.BorderLayout.CENTER);
        horizontalTrackPanel.setOpaque(false);
        horizontalTrackPanel.setLayout(new BorderLayout());
        if(horizontalTrack==null)horizontalTrack=StandardLabel{};
        horizontalTrackPanel.add(horizontalTrack.getJComponent(),java.awt.BorderLayout.CENTER);
        if(upOn==null)upOn=crudfx.util.resources.ResourceLoader.imageIcon("crudfx16.png");
        if(upOff==null)upOff=crudfx.util.resources.ResourceLoader.imageIcon("crudfx16.png");
        if(downOn==null)downOn=crudfx.util.resources.ResourceLoader.imageIcon("crudfx16.png");
        if(downOff==null)downOff=crudfx.util.resources.ResourceLoader.imageIcon("crudfx16.png");
        if(leftOn==null)leftOn=crudfx.util.resources.ResourceLoader.imageIcon("crudfx16.png");
        if(leftOff==null)leftOff=crudfx.util.resources.ResourceLoader.imageIcon("crudfx16.png");
        if(rightOn==null)rightOn=crudfx.util.resources.ResourceLoader.imageIcon("crudfx16.png");
        if(rightOff==null)rightOff=crudfx.util.resources.ResourceLoader.imageIcon("crudfx16.png");
        GridTools.installScrollBars(this.scrollPane
            ,upOn,upOff,downOn,downOff,leftOn,leftOff,rightOn,rightOff
            ,verticalTrackPanel
            ,verticalThumbPanel
            ,horizontalTrackPanel
            ,horizontalThumbPanel
            );
        scrollPane.setCorner(ScrollPaneConstants.UPPER_RIGHT_CORNER,new JLabel(""));
        return scrollPane;
        }
}
